package com.lsp.server;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName TestRedis
 * @Description TODO
 * @Author Mr Hao
 * @Date 2021/12/5 17:07
 */
@RestController
@RequestMapping("redis")
public class TestRedis {

    @Autowired
    private RedisTemplate redisTemplate;
    @GetMapping("set")
    public String test(String key,String value){
        redisTemplate.opsForValue().set(key,value);
        return "success";
    }

    @GetMapping("get")
    public String test2(String key){
        return (String) redisTemplate.opsForValue().get(key);
    }
}
